using FluentNHibernate.Conventions;
using FluentNHibernate.Mapping;
using Webshop20.Domain.Security.Authentication.Core;

namespace Webshop20.Infrastructure.Persistence.NH.AutoMappings.Conventions.Particular
{
    public class AccountConventions : IPropertyConvention
    {
        public bool Accept(IProperty target)
        {
            return target.EntityType.Name == typeof(Account).Name; 
        }

        public void Apply(IProperty target)
        {
            if (target.Property.Name == "LoginName")
                target
                    .Unique()
                    .Not.Nullable();
        }
    }
}